package com.medical.goods.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.medical.common.utils.PageUtils;
import com.medical.common.utils.Query;

import com.medical.goods.dao.TypeDao;
import com.medical.goods.entity.TypeEntity;
import com.medical.goods.service.TypeService;


@Service("typeService")
public class TypeServiceImpl extends ServiceImpl<TypeDao, TypeEntity> implements TypeService {

    @Autowired
    private TypeDao typeDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params,TypeEntity typeEntity) {
        QueryWrapper<TypeEntity> wrapper = new QueryWrapper<>();
        if(typeEntity !=null){
            if(typeEntity.getTname()!=null && typeEntity.getTname().length()>0){
                wrapper.like("tname",typeEntity.getTname());
            }
        }
        IPage<TypeEntity> page = this.page(
                new Query<TypeEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

    @Override
    public List<TypeEntity> tlist(TypeEntity typeEntity) {
        return typeDao.tlist(typeEntity);
    }

}